﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Simple.Repository.Migrations
{
    public partial class _12 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Class_Dynamic",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    Content = table.Column<string>(type: "longtext", nullable: false, comment: "动态内容")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ClassIds = table.Column<string>(type: "longtext", nullable: false, comment: "班级Id集合")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    State = table.Column<int>(type: "int", nullable: false, comment: "状态0-草稿，1已发布,2已屏蔽"),
                    CreateUserName = table.Column<string>(type: "longtext", nullable: false, comment: "发布人姓名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Class_Dynamic", x => x.Id);
                },
                comment: "班级动态表")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Class_DynamicImage",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    FiledId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "文件Id", collation: "ascii_general_ci"),
                    FileName = table.Column<string>(type: "longtext", nullable: false, comment: "文件名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FileSize = table.Column<string>(type: "longtext", nullable: false, comment: "文件大小")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ClassDynamicId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "班级动态Id", collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Class_DynamicImage", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Class_DynamicImage_Class_Dynamic_ClassDynamicId",
                        column: x => x.ClassDynamicId,
                        principalTable: "Class_Dynamic",
                        principalColumn: "Id");
                },
                comment: "班级动态图片表")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Class_DynamicLeaveMessage",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    LeaveMessageContent = table.Column<string>(type: "longtext", nullable: false, comment: "留言内容")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreateUserName = table.Column<string>(type: "longtext", nullable: false, comment: "留言人姓名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ClassDynamicId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "班级动态Id", collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Class_DynamicLeaveMessage", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Class_DynamicLeaveMessage_Class_Dynamic_ClassDynamicId",
                        column: x => x.ClassDynamicId,
                        principalTable: "Class_Dynamic",
                        principalColumn: "Id");
                },
                comment: "班级动态留言表")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_Class_DynamicImage_ClassDynamicId",
                table: "Class_DynamicImage",
                column: "ClassDynamicId");

            migrationBuilder.CreateIndex(
                name: "IX_Class_DynamicLeaveMessage_ClassDynamicId",
                table: "Class_DynamicLeaveMessage",
                column: "ClassDynamicId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Class_DynamicImage");

            migrationBuilder.DropTable(
                name: "Class_DynamicLeaveMessage");

            migrationBuilder.DropTable(
                name: "Class_Dynamic");
        }
    }
}
